/**
 * 全局的方法、变量、属性...
 */
import Vue from 'vue';
import store from '@/vuex/index'; //vuex
import "@/assets/css/init.scss"; //初始化样式
import api from '@/api/api.js'; //公共的请求
import ElementUI from 'element-ui'; //element-ui
import 'element-ui/lib/theme-chalk/index.css'; //element-ui
import '@/assets/iconfont/iconfont.css'; //阿里iconfont
import echarts from 'echarts'; //百度echarts
import 'echarts-gl'; //百度GL
import world from 'echarts/map/js/world.js'; //百度echarts 相关

Vue.prototype.$echarts = echarts;
Vue.prototype.getViewportSize = getViewportSize;
Vue.prototype.$api = api;
Vue.prototype.$vuex = store;
Vue.prototype.$bus = Bus();
Vue.prototype.$sysTheme = sysTheme;
Vue.use(ElementUI);
Vue.config.productionTip = false;

function Bus() {
  return new Vue();
}

//获取屏幕宽高
function getViewportSize() {
  return {
    width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
    height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  };
}

//系统默认主题
function sysTheme() {
  let obj = {};
  obj.theme_color = '#409eff';
  obj.level2_bg_color = '#333333'; //二级菜单背景色
  obj.level2_txt_color = '#ffffff';
  let theme = localStorage.getItem('sysTheme') || null;
  if (theme) {
    try {
      theme = JSON.parse(theme);
      obj.theme_color = theme.theme_color;
      obj.level2_bg_color = theme.level2_bg_color;
    } catch (err) {}
  }
  return obj;
}
